﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class DeviceBase : MonoBehaviour
{
    public string Name;

    [SerializeField]
    protected string Type;

    [SerializeField]
    protected string Id;

    public string GetDevType() { return Type; }
    public void SetDevType(string type) { Type = type; }
    public string GetDevId() { return Id; }
    public void SetDevId(string id) { Id = id; }

    protected virtual void Start()
    {
        DeviceManager.Instance?.Reg(this);
    }

    protected virtual void OnDestroy()
    {
        DeviceManager.Instance?.UnReg(this);
    }

    public abstract void Clear();
    public abstract void ClearToMin();
    public abstract void ClearToMax();

    public virtual bool HandleCmd(string cmd, string args)
    {
        return false;
    }

    public abstract string GetDeviceStatusCore();

    public DeviceStatus GetDeviceStatus()
    {
        DeviceStatus status = new DeviceStatus();
        status.DevType = Type;
        status.DevId = Id;
        status.DevMsg = GetDeviceStatusCore();
        return status;
    }
}
